package com.vf.admin.client.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.miaodong.entity.AppPaySetup;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * 支付后台设置
 */
@Repository
public class AppPaySetupDao extends BaseDao<AppPaySetup> {

    /**
     * 所有列表
     */
    public List<AppPaySetup> getList(Integer payType) {
        ArrayList<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from app_pay_setup where status='2' and  pay_type = ?");
        String sql = sbStr.toString();
        paramList.add(payType);
        return this.queryList(sql, paramList, AppPaySetup.class);
    }

    /**
     * 添加/修改
     */
    public void save(AppPaySetup haoYou) {
        if (haoYou.getId() != null && haoYou.getId() > 0) {
            this.update(haoYou);
        } else {
            haoYou.setId(this.add(haoYou));
        }
    }

    /**
     * 删除
     */
    public void del(Integer id) {
        if (id <= 0) {
            return;
        }
        String sql = "delete  from app_pay_setup where id = ?";
        ArrayList<Object> paramList = new ArrayList<Object>();
        paramList.add(id);
        this.del(sql, paramList);
    }

    /**
     * 删除
     */
    public AppPaySetup getByAppId(String appIdStr) {
        String sql = "select * from app_pay_setup where app_id_str = ?";
        ArrayList<Object> paramList = new ArrayList<Object>();
        paramList.add(appIdStr);
        return this.queryObj(sql, paramList, AppPaySetup.class);
    }
}
